package com.iRomantic.controller.manager;

import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.iRomantic.common.BaseController;
import com.iRomantic.config.Constant;
import com.iRomantic.domain.entity.Picture;
import com.jfinal.upload.UploadFile;

public class PictureController extends BaseController {
	
	private static final Logger logger = LoggerFactory.getLogger(PictureController.class);
	
	/**
	 * 创建图片
	 * @throws Exception 
	 */
	public void create() throws Exception{
		String path = this.getSession().getServletContext().getRealPath(Constant.TEMP_FOLDER);
		//保存图片
		UploadFile pic = this.getFile("file",path);
		Picture picture = this.getModel(Picture.class);
		picture.initAttrByUpload(pic,path);
		picture.save();
		this.renderJson(picture);
		
	}

}
